<template>
  <div class='search'>
    <f-form ref='form' :action='api.busOrder' :form-key='this.formItem.orderId'>
      <a-divider orientation='left'>
        订单附件资料
      </a-divider>
      <f-form-item type='upload' name='orderImage' :value='formItem.orderImage' :file-max='50' :disabled='readOnly' :busId='orderId' busType='Order' :realRemove='true' />

      <div v-if='paymentId'>
        <a-divider orientation='left'>
          资金支付附件
        </a-divider>
        <f-form-item type='upload' name='paymentImage' :value='formItem.paymentImage' :file-max='50' :disabled='readOnly' :busId='paymentId' busType='BusPayment' :realRemove='true' @uploadSuccess='uploadSuccess' />
      </div>
    </f-form>
  </div>
</template>
<script>
import api from "../../js/api"


export default {
  name: "OrderAttachment",
  props: {},
  data() {
    return {
      refs: this.$refs,
      orderId: "",
      paymentId: "",
      readOnly: false,
      api: Object.assign(api, this.api),
      isAdd: true,//是否是添加模式
      loaded: false,//是否加载完成
      formItem: this.getFormItem()
    }
  },
  methods: {
    getFormItem() {
      return {
        orderId: "",
        remark: "",
        orderImage: []
      }
    },
    //文件上传回调
    uploadSuccess(fileUrl, files, fileIds) {
      this.fileIds = fileIds
    },

    //表单赋值
    setData(data, readOnly) {
      if (readOnly) {
        this.readOnly = readOnly
      }
      this.$refs.form.resetFields()
      this.formItem = this.getFormItem()
      if (data && data.orderId) {
        let params = {
          orderId: data.orderId,
          paymentId: data.paymentId
        }
        this.orderId = data.orderId
        this.paymentId = data.paymentId
        this.refs["form"].getDetails(params, (data) => {
          this.formItem = data
          this.loaded = true
        })
        this.isAdd = false
      } else {
        this.loaded = true
      }
    }

  },
  mounted() {

  },
  created() {
  },
  components: {}
}
</script>

<style scoped lang='less' rel='stylesheet/less'>

</style>
